package hibernate.xml23;

import org.hibernate.Session;
import org.hibernate.Transaction;

public class InitDate {

	
	public static void main(String[] args) {
		Session session = null;
		Transaction tx = null;
		try {
			session = HibernateUtil.getSession();
			tx = session.beginTransaction();
			Group group =new Group();
			group.setName("A13-1");
			
			session.save(group);
			
			User user1 = new User();
			user1.setName("a000");
			user1.setGroup(group);
			User user2 = new User();
			user2.setName("a001");
			user2.setGroup(group);
			
			session.save(user1);
			session.save(user2);
			tx.commit();
		} catch (Exception e) {
			e.printStackTrace();
			tx.rollback();
		} finally {
			HibernateUtil.closeSession(session);
		}

	}

}
